<template>
  <div class="reportFormPage">
    <div class="report-dom">
      <el-row>
        <el-col :span="5" :offset="19">
          <div class="pageNumBox">
            <span>第</span>
            <span class="placeholder-min text-center">&nbsp;{{ form.page }}&nbsp;</span>
            <span>页，共</span>
            <span class="placeholder-min text-center">&nbsp;{{ form.totalPage }}&nbsp;</span>
            <span>页</span>
          </div>
        </el-col>
      </el-row>
      <div class="topTwoBox">
        <div class="centerName">粉煤灰含水率、比表面积试验检测记录表</div>
        <div class="codeText">
          <tr>
            JGLQ09015
          </tr>
          <tr>
            JGLQ09014
          </tr>
        </div>
      </div>
      <div class="threeTopBox">
        <div class="left-border">
          <div class="box-title">检测单位名称：</div>
          <div class>{{ form.jiancdwmc }}</div>
        </div>
        <div class="right-border">
          <span>记录编号：</span>
          <span class="placeholder">{{ form.jilbh }}</span>
        </div>
      </div>
      <div class="table-border">
        <!-- .........................1111111111111111111111111111111......................................................... -->
        <table height="220px" class="top-table">
          <tbody>
            <tr>
              <td height="30" align="center" width="15%">
                <span style="width: 90px; display: inline-block">工程名称</span>
              </td>
              <td width="35%" class="text-center">
                <span>{{ form.gongcmc }}</span>
              </td>
              <td align="center" width="15%">
                <span style="width: 90px; display: inline-block">工程部位/用途</span>
              </td>
              <td width="35%" class="text-center">
                <span>{{ form.gongcbwyt }}</span>
              </td>
            </tr>
            <tr>
              <td height="50" align="center">样品信息</td>
              <td class="specimen-border" colspan="3">
                <span>样品名称：</span>
                <span :class="{ placeholder: !form.yangpmc }">{{ form.yangpmc }}</span>
                <span>；样品编号：</span>
                <span :class="{ 'placeholder-long': !form.yangpbh }">{{ form.yangpbh }}</span>

                <span>；样品数量：</span>
                <span :class="{ placeholder: !form.yangpsl }">{{ form.yangpsl }}</span>
                <span>；样品状态：</span>
                <span :class="{ placeholder: !form.yangpzt }">{{ form.yangpzt }}</span>
                <span>；来样时间：</span>
                <span :class="{ placeholder: !form.yangpsj }">{{ form.yangpsj }}</span>
              </td>
            </tr>

            <tr>
              <td height="25" align="center" width="15%">
                <span style="width: 90px; display: inline-block">试验检测日期</span>
              </td>
               <!-- <td width="35%" class="text-center">{{ form.shiyjcrq }}</td> -->                                            
 <td width="35%" class="text-center">
      <el-input v-model="form.shiyjcrq" />
</td>
              <td align="center" width="15%">
                <span style="width: 90px; display: inline-block">试验条件</span>
              </td>
              <td v-if="isPdf" width="35%">
                温度：
                <span style="display: inline-block; width: 10%">{{ form.shiytjwd }}</span>
                ℃；湿度：
                <span style="display: inline-block; width: 10%">{{ form.shiytjsd }}</span
                >%RH
              </td>
              <td v-else width="35%">
                温度：
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.shiytjwd" style="width: 15%" />℃；湿度：
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.shiytjsd" style="width: 15%" />%RH
              </td>
            </tr>

            <tr>
              <td height="50" align="center" width="15%">
                <span style="width: 90px; display: inline-block">检测依据</span>
              </td>
              <td width="35%">
                <span v-if="isPdf">{{ form.jiancyj }}</span>
                <el-input v-else type="textarea" v-model="form.jiancyj" :rows="2" class="mark" @dblclick.native="showBsJiancyjView" readonly />
              </td>
              <td align="center" width="15%">
                <span style="width: 90px; display: inline-block">判定依据</span>
              </td>
              <td width="35%">
                <span v-if="isPdf">{{ form.pandyj }}</span>
                <el-input v-else type="textarea" v-model="form.pandyj" :rows="2" @dblclick.native="showBsJudgeBaseView" @focus="handleFocus('pandyj')" class="mark" />
              </td>
            </tr>
            <tr class="bottom-border">
              <td height="50" align="center">
                <div>主要仪器设备</div>
                <div>名称及编号</div>
              </td>
              <td colspan="3">
                <span v-if="isPdf">{{ form.zhuyyqsbmcjbh }}</span>
                <el-input v-else type="textarea" :rows="2" v-model="form.zhuyyqsbmcjbh" class="height100 width100 mark" @dblclick.native="showBsInstrumentView" readonly></el-input>
              </td>
            </tr>
          </tbody>
        </table>
        <!-- .................................22222222222222222222222222222222............................................... -->
        <table height="500px" class="middle-table">
          <tbody>
            <tr trindex="0">
              <td colspan="10" rowspan="1" class="td-height1">含水量（%）</td>
            </tr>
            <tr trindex="1">
              <td colspan="2" rowspan="1" class="td-height1">试验次数</td>
              <td colspan="1" rowspan="1" class="td-height1">盒号</td>
              <td colspan="1" rowspan="1" class="td-height1">盒质量（g）</td>
              <td colspan="1" rowspan="1" class="td-height1">盒+湿试样质量（g）</td>
              <td colspan="1" rowspan="1" class="td-height1">盒+干试样质量（g）</td>
              <td colspan="1" rowspan="1" class="td-height1">水质量（g）</td>
              <td colspan="1" rowspan="1" class="td-height1">干试样质量（g）</td>
              <td colspan="1" rowspan="1" class="td-height1">含水率（%）</td>
              <td colspan="1" rowspan="1" class="td-height1">平均含水率（%）</td>
            </tr>
            <tr trindex="2">
              <td colspan="2" rowspan="1" class="td-height1">1</td>
              <td colspan="1" rowspan="1" class="td-height1">
                <el-input v-model="form.a11Heh" class="pointer mark" @dblclick.native="showBaQjDetailView('1')" readonly />
              </td>
              <td colspan="1" rowspan="1" class="td-height1">
                <span>{{ form.a12 }}</span>
              </td>
              <td colspan="1" rowspan="1" class="td-height1">
                <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.a13" @blur="a3Change('1')" @keydown.native="handleKeyDown($event, 0, 0)" :ref="'0_0'" />
              </td>
              <td colspan="1" rowspan="1" class="td-height1">
                <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.a14" @blur="a4Change('1')" @keydown.native="handleKeyDown($event, 0, 1)" :ref="'0_1'" />
              </td>
              <td colspan="1" rowspan="1" class="td-height1">
                <el-input type="text" disabled tabindex="200" v-model="form.a15" />
              </td>
              <td colspan="1" rowspan="1" class="td-height1">
                <el-input type="text" disabled tabindex="200" v-model="form.a16" />
              </td>
              <td colspan="1" rowspan="1" class="td-height1">
                <el-input type="text" disabled tabindex="200" v-model="form.a17" />
              </td>
              <td colspan="1" rowspan="2" class="td-height1">
                <el-input type="text" disabled tabindex="200" v-model="form.a18Pjhsl" />
              </td>
            </tr>
            <tr trindex="3">
              <td colspan="2" rowspan="1" class="td-height1">2</td>
              <td colspan="1" rowspan="1" class="td-height1">
                <el-input v-model="form.a21Heh" class="pointer mark" @dblclick.native="showBaQjDetailView('2')" readonly />
              </td>
              <td colspan="1" rowspan="1" class="td-height1">
                <span>{{ form.a22 }}</span>
              </td>
              <td colspan="1" rowspan="1" class="td-height1">
                <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.a23" @blur="a3Change('2')" @keydown.native="handleKeyDown($event, 1, 0)" :ref="'1_0'" />
              </td>
              <td colspan="1" rowspan="1" class="td-height1">
                <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.a24" @blur="a4Change('2')" @keydown.native="handleKeyDown($event, 1, 1)" :ref="'1_1'" />
              </td>
              <td colspan="1" rowspan="1" class="td-height1">
                <el-input type="text" disabled tabindex="200" v-model="form.a25" />
              </td>
              <td colspan="1" rowspan="1" class="td-height1">
                <el-input type="text" disabled tabindex="200" v-model="form.a26" />
              </td>
              <td colspan="1" rowspan="1" class="td-height1">
                <el-input type="text" disabled tabindex="200" v-model="form.a27" />
              </td>
            </tr>
            <tr trindex="4">
              <td colspan="10" rowspan="1" class="td-height1">粉煤灰比表面积（勃氏法）</td>
            </tr>
            <tr trindex="5">
              <td colspan="1" rowspan="2" class="td-height1">试验次数</td>
              <td colspan="1" rowspan="2" class="td-height1">校准温度(℃)</td>
              <td colspan="1" rowspan="2" class="td-height1">标准粉密度(g/cm<sup>3</sup>)</td>
              <td colspan="2" rowspan="2" class="td-height1">标准粉质量（g）</td>
              <td colspan="1" rowspan="2" class="td-height1">标准粉比表面积(m<sup>2</sup>/kg)</td>
              <td colspan="1" rowspan="2" class="td-height1">标准粉降落时间(s)</td>
              <td colspan="3" rowspan="1" class="td-height1">仪器K值</td>
            </tr>
            <tr trindex="6">
              <td colspan="1" rowspan="1" class="td-height1">单值</td>
              <td colspan="2" rowspan="1" class="td-height1">均值</td>
            </tr>
            <tr trindex="7">
              <td colspan="1" rowspan="1" class="td-height1">1</td>
              <td colspan="1" rowspan="1" class="td-height1">
                <!-- <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.b11" /> -->
                <el-select v-model="form.b11" class="hide-icon height100" placeholder>
                  <el-option v-for="(item, index) in shuiwenList" :key="index" :label="item.temp" :value="item.temp"></el-option>
                </el-select>
              </td>
              <td colspan="1" rowspan="2" class="td-height1">
                <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.b12Bzfmd" @blur="calculateBbmjAll()"  @keydown.native="handleKeyDown($event, 2, 0)" :ref="'2_0'"/>
              </td>
              <td colspan="2" rowspan="2" class="td-height1">
                <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.b13Bzfzl"  @keydown.native="handleKeyDown($event, 2, 1)" :ref="'2_1'"/>
              </td>
              <td colspan="1" rowspan="2" class="td-height1">
                <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.b14Bzfbbmj"  @keydown.native="handleKeyDown($event, 2, 2)" :ref="'2_2'"/>
              </td>
              <td colspan="1" rowspan="1" class="td-height1">
                <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.b15" @blur="calculateBbmj(1)"  @keydown.native="handleKeyDown($event, 2, 3)" :ref="'2_3'"/>
              </td>
              <td colspan="1" rowspan="1" class="td-height1">
                <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.b16" @blur="calculateB17Jz()"  @keydown.native="handleKeyDown($event, 2, 4)" :ref="'2_4'"/>
              </td>
              <td colspan="2" rowspan="2" class="td-height1">
                <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.b17Jz" disabled />
              </td>
            </tr>
            <tr trindex="8">
              <td colspan="1" rowspan="1" class="td-height1">2</td>
              <td colspan="1" rowspan="1" class="td-height1">
                <!-- <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.b21" /> -->
                <el-select v-model="form.b21" class="hide-icon height100" placeholder>
                  <el-option v-for="(item, index) in shuiwenList" :key="index" :label="item.temp" :value="item.temp"></el-option>
                </el-select>
              </td>
              <td colspan="1" rowspan="1" class="td-height1">
                <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.b25" @blur="calculateBbmj(2)"  @keydown.native="handleKeyDown($event, 3, 0)" :ref="'3_0'"/>
              </td>
              <td colspan="1" rowspan="1" class="td-height1">
                <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.b26" @blur="calculateB17Jz()"  @keydown.native="handleKeyDown($event, 3, 1)" :ref="'3_1'"/>
              </td>
            </tr>
            <tr trindex="9">
              <td colspan="2" rowspan="1" class="td-height1">试样密度(g/cm<sup>3</sup>)</td>
              <td colspan="1" rowspan="1" class="td-height1">试样空隙率ε</td>
              <td colspan="2" rowspan="1" class="td-height1">标准试样空隙率</td>
              <td colspan="2" rowspan="1" class="td-height1">试料层体积V(cm<sup>3</sup>)</td>
              <td colspan="3" rowspan="1" class="td-height1">试样量m(g) m=ρv(1-ε）</td>
            </tr>
            <tr trindex="10">
              <td colspan="2" rowspan="1" class="td-height1">
                <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.c1Symd" @blur="calculateShiylBbmjAll()"  @keydown.native="handleKeyDown($event, 4, 0)" :ref="'4_0'"/>
              </td>
              <td colspan="1" rowspan="1" class="td-height1">
                <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.c2Sykxl" @blur="calculateShiylBbmjAll()"  @keydown.native="handleKeyDown($event, 4, 1)" :ref="'4_1'"/>
              </td>
              <td colspan="2" rowspan="1" class="td-height1">
                <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.c3Bzsykxl" @blur="calculateBbmjAll()"  @keydown.native="handleKeyDown($event, 4, 2)" :ref="'4_2'"/>
              </td>
              <td colspan="2" rowspan="1" class="td-height1">
                <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.c4Slctj" @blur="calculateShiyl()"  @keydown.native="handleKeyDown($event, 4, 3)" :ref="'4_3'"/>
              </td>
              <td colspan="3" rowspan="1" class="td-height1">
                <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.c5Syl" disabled />
              </td>
            </tr>
            <tr trindex="11">
              <td colspan="1" rowspan="1" class="td-height1">试验次数</td>
              <td colspan="1" rowspan="1" class="td-height1">试验温度(℃)</td>
              <td colspan="1" rowspan="1" class="td-height1">标准粉比表面积(m<sup>2</sup>/kg)</td>
              <td colspan="2" rowspan="1" class="td-height1">被测试样试验时，压力计液面降落测得的时间(s)</td>
              <td colspan="1" rowspan="1" class="td-height1">被测试样试验温度下的空气粘度 (µPa·s)</td>
              <td colspan="1" rowspan="1" class="td-height1">标准试样试验温度下的空气粘度 (µPa·s)</td>
              <td colspan="1" rowspan="1" class="td-height1">被测试样的比表面积(m<sup>2</sup>/kg)</td>
              <td colspan="2" rowspan="1" class="td-height1">平均值(m<sup>2</sup>/kg)</td>
            </tr>
            <tr trindex="12">
              <td colspan="1" rowspan="1" class="td-height1">1</td>
              <td colspan="1" rowspan="1" class="td-height1">
                <el-select v-model="form.d11" class="hide-icon height100" placeholder @change="wenduChange(1)">
                  <el-option v-for="(item, index) in shuiwenList" :key="index" :label="item.temp" :value="item.temp"></el-option>
                </el-select>
                <!-- <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.d11" /> -->
              </td>
              <td colspan="1" rowspan="2" class="td-height1">
                <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.d12Bzfbbmj" @blur="calculateBbmjAll()"  @keydown.native="handleKeyDown($event, 5, 0)" :ref="'5_0'"/>
              </td>
              <td colspan="2" rowspan="1" class="td-height1">
                <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.d13" @blur="calculateBbmj(1)"  @keydown.native="handleKeyDown($event, 5, 1)" :ref="'5_1'"/>
              </td>
              <td colspan="1" rowspan="1" class="td-height1">
                <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.d14" disabled />
              </td>
              <td colspan="1" rowspan="1" class="td-height1">
                <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.d15" disabled />
              </td>
              <td colspan="1" rowspan="1" class="td-height1">
                <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.d16"  @keydown.native="handleKeyDown($event, 5, 2)" :ref="'5_2'"/>
              </td>
              <td colspan="2" rowspan="2" class="td-height1">
                <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.d17Pjz"  @keydown.native="handleKeyDown($event, 5, 3)" :ref="'5_3'"/>
              </td>
            </tr>
            <tr trindex="13">
              <td colspan="1" rowspan="1" class="td-height1">2</td>
              <td colspan="1" rowspan="1" class="td-height1">
                <el-select v-model="form.d21" class="hide-icon height100" placeholder @change="wenduChange(2)">
                  <el-option v-for="(item, index) in shuiwenList" :key="index" :label="item.temp" :value="item.temp"></el-option>
                </el-select>
              </td>
              <td colspan="2" rowspan="1" class="td-height1">
                <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.d23" @blur="calculateBbmj(2)"  @keydown.native="handleKeyDown($event, 6, 0)" :ref="'6_0'"/>
              </td>
              <td colspan="1" rowspan="1" class="td-height1">
                <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.d24" disabled />
              </td>
              <td colspan="1" rowspan="1" class="td-height1">
                <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.d25" disabled />
              </td>
              <td colspan="1" rowspan="1" class="td-height1">
                <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.d26"  @keydown.native="handleKeyDown($event, 6, 1)" :ref="'6_1'"/>
              </td>
            </tr>
          </tbody>
        </table>
        <!-- .....................................................33333333333333333................................................... -->
        <table height="100px" class="bottom-table">
          <tr>
            <td>
              <span v-if="isPdf" class="textarea-span">{{ form.fujsm }}</span>
              <el-input v-else type="textarea" :rows="2" v-model="form.fujsm" @focus="handleFocus('fujsm')" />
            </td>
          </tr>
        </table>
      </div>
      <!-- .................................44444444444............................................. -->
      <table height="22px" class="transparent">
        <tbody>
          <tr>
            <td width="10%" align="right">检测：</td>
            <td width="15%" align="left"></td>
            <td width="10%" align="right">记录：</td>
            <td width="15%" align="left"></td>
            <td width="10%" align="right">复核：</td>
            <td align="left" width="15%"></td>
            <td width="10%">日期：</td>
            <td align="left" width="15%">
              <div style="display: inline-block; margin-left: 20px">年</div>
              <div style="display: inline-block; margin-left: 20px">月</div>
              <div style="display: inline-block ;margin-left: 20px">日</div>
            </td>
          </tr>
        </tbody>
      </table>
    </div>
    <bs-instrument-view ref="bsInstrumentViewRef" @select="selectInstrument"></bs-instrument-view>
    <ba-qj-detail-view ref="baQjDetailViewRef" :excelId="excelId" :shiyjcrq="form.shiyjcrq" @select="selectBaQjDetail"></ba-qj-detail-view>
    <bs-jiancyj-view ref="bsJiancyjViewRef" @select="selectJiancyj" :syType="syType"></bs-jiancyj-view>
    <bs-judge-base-view ref="bsJudgeBaseViewRef" @select="selectJudge" :syType="syType"></bs-judge-base-view>
  </div>
</template>

<script>
import { getChlFmhhslBsInfo } from "@/api/report_chl/chlFmhhslBsInfo";
import { listBySyTypeId } from "@/api/sycs/dataBase";

import BsInstrumentView from "@/views/dept/bsInstrument/BsInstrumentView.vue";
import BaQjDetailView from "@/views/sycs/baQjDetail/BaQjDetailView.vue";
import BsJiancyjView from "@/views/sycs/bsJiancyj/BsJiancyjView.vue";
import BsJudgeBaseView from "@/views/sycs/bsJudgeBase/BsJudgeBaseView.vue";

import decimal from "@/utils/big-decimal";
import { handleFocus, emptyConvert, handleKeyDown } from "@/views/reportForms/utils";
import Bus from "@/utils/bus";
export default {
  name: "fmhhsl",
  components: {
    BsInstrumentView,
    BaQjDetailView,
    BsJiancyjView,
    BsJudgeBaseView
  },
  props: {
    excelId: {
      type: [String, Number],
      default: () => ""
    },
    syType: {
      type: [String, Number],
      default: () => ""
    },
    page: {
      type: Number,
      default: () => 0
    },
    isPdf: {
      type: Boolean,
      default: () => false
    },
    printEmpty: {
      type: Boolean,
      default: () => false
    }
  },
  data() {
    return {
      params: {},
      query: {},
      // 表单参数
      form: {},
      shuiwenList: []
    };
  },
  watch: {
    isPdf(newVal, oldVal) {
      this.form = { ...emptyConvert(this.form, newVal) };
    }
  },
  created() {
    this.getInfo();
    this.getShuiwenList();
  },
  methods: {
    // 获取详情
    getInfo() {
      getChlFmhhslBsInfo(this.excelId || this.$defaultExcelId).then((response) => {
        this.form = response.data;
        if (!this.form.fujsm) {
          this.form.fujsm = "附加声明：";
        }
      });
    },
    getShuiwenList() {
      listBySyTypeId({ syYjId: "2143842384353" }).then((response) => {
        const data = response.data;
        this.shuiwenList = data.page.records;
      });
    },
    // 显示检测依据列表
    showBsJiancyjView() {
      this.$refs.bsJiancyjViewRef.init(this.form.jiancyjIds);
    },
    // 检测依据选择
    selectJiancyj(info) {
      this.form.jiancyj = info.label;
      this.form.jiancyjIds = info.ids;
      Bus.$emit("setFmhBgJiancyj", { jiancyj: this.form.jiancyj, jiancyjIds: this.form.jiancyjIds });
    },
    // 显示判定依据列表
    showBsJudgeBaseView() {
      this.$refs.bsJudgeBaseViewRef.init(this.form.pandyjIds);
    },
    // 判断依据选择
    selectJudge(info) {
       this.form.pandyjIds = info.ids;
      this.form.pandyj = info.label;
    },
    // 显示仪器列表
    showBsInstrumentView() {
      this.$refs.bsInstrumentViewRef.init(this.form.shebIds);
    },
    // 仪器选择
    selectInstrument(info) {
      this.form.zhuyyqsbmcjbh = info.label;
      this.form.shebIds = info.ids;
      Bus.$emit("setFmhBgZhuyyqsbmcjbh", { zhuyyqsbmcjbh: this.form.zhuyyqsbmcjbh, shebIds: this.form.shebIds });
    },
    // 显示盒号列表
    showBaQjDetailView(type) {
      this.collectHehId();
      this.$refs.baQjDetailViewRef.init(type, this.form.hehIdList);
    },
    // 盒号选择
    selectBaQjDetail(type, obj) {
      this.form["a" + type + "1Heh"] = obj.hh;
      this.form["a" + type + "1HehId"] = obj.detailId;
      this.form["a" + type + "2"] = obj.quality;
      this.calculateGanzl(type);
    },
    // 盒+ 湿样质量
    a3Change(type) {
      this.calculateShuizl(type);
      this.calculateGanzl(type);
      this.calculateHansl(type);
    },
    // 盒+干试样质量
    a4Change(type) {
      this.calculateShuizl(type);
      this.calculateHansl(type);
    },
    // 计算水质量
    calculateShuizl(type) {
      //  E=c-d
      if (!this.form["a" + type + "3"] || !this.form["a" + type + "4"]) {
        return;
      }
      this.form["a" + type + "5"] = decimal.subtract(this.form["a" + type + "3"], this.form["a" + type + "4"]);
      // this.calculateHansl(type);
    },
    // 计算干试样质量
    calculateGanzl(type) {
      //  F=c-b
      if (!this.form["a" + type + "2"] || !this.form["a" + type + "3"]) {
        this.form["a" + type + "6"] = null;
        return;
      }
      this.form["a" + type + "6"] = decimal.subtract(this.form["a" + type + "3"], this.form["a" + type + "2"]);
      // this.calculateHansl(type);
    },
    // 计算含水率
    calculateHansl(type) {
      //  G=E/F
      if (!this.form["a" + type + "5"] || !this.form["a" + type + "6"]) {
        this.form["a" + type + "7"] = null;
        this.form["a18Pjhsl"] = null;
        return;
      }
      this.form["a" + type + "7"] = decimal.divide(decimal.multiply(this.form["a" + type + "5"], 100), this.form["a" + type + "6"], 1);
      this.calculatePjhsl();
    },
    // a18Pjhsl 计算平均含水率
    calculatePjhsl() {
      if (!this.form["a17"] || !this.form["a27"]) {
        this.form["a18Pjhsl"] = null;
        return;
      }
      this.form["a18Pjhsl"] = decimal.divide(decimal.add(this.form["a17"], this.form["a27"]), 2, 1);
      this.setFmhBgHansl();
    },
    // 仪器K值平均值 b17Jz
    calculateB17Jz() {
      if (!this.form["b16"] || !this.form["b26"]) {
        this.form["b17Jz"] = null;
        return;
      }
      this.form["b17Jz"] = decimal.divide(decimal.add(this.form["b16"], this.form["b26"]), 2, 1);
      this.setFmhBgHansl();
    },
    // 给报告传值含水率
    setFmhBgHansl() {
      if (this.page != 0) {
        return;
      }
      Bus.$emit("setFmhBgJiancjg", [{ key: 93, value: this.form.a18Pjhsl }]);
    },
    // 计算试样量m
    calculateShiyl() {
      if (!this.form["c1Symd"] || !this.form["c2Sykxl"] || !this.form["c4Slctj"]) {
        this.form["c5Syl"] = null;
        return;
      }
      //  m= l*o*(1-m)
      const l = this.form["c1Symd"];
      const m = this.form["c2Sykxl"];
      const o = this.form["c4Slctj"];
      // a = 1-m
      const a = decimal.subtract(1, m, 3);
      this.form["c5Syl"] = decimal.multiply(decimal.multiply(l, o, 3), a, 3);
    },
    calculateShiylBbmjAll() {
      this.calculateShiyl();
      this.calculateBbmjAll();
    },
    calculateBbmjAll() {
      this.calculateBbmj(1);
      this.calculateBbmj(2);
    },
    // 计算比表面积
    calculateBbmj(index) {
      // r*√s*(1-n)*√m³*c / √f*(1-m)*√n³*l
      const r = this.form["d12Bzfbbmj"]; // 标准粉比表面积
      const s = this.form["d" + index + "3"]; // 被测试样试验时，压力计液面降落测得的时间
      const n = this.form["c3Bzsykxl"]; // 标准试样空隙率
      const c = this.form["b12Bzfmd"]; // 标准粉密度
      const f = this.form["b" + index + "5"]; // 标准粉降落时间
      const m = this.form["c2Sykxl"]; // 试样空隙率
      const l = this.form["c1Symd"]; // 试样密度

      if (!r || !s || !n || !c || !f || !m || !l) {
        this.form["d" + index + "6"] = null;
        return;
      }
      // r*√s*(1-n)*√m³*c
      const arr1 = [r, Math.sqrt(s), decimal.subtract(1, n), Math.sqrt(Math.pow(m, 3)), c];
      let num1 = 1;
      arr1.forEach((item) => {
        num1 = decimal.multiply(num1, item, 18);
      });
      // √f*(1-m)*√n³*l
      const arr2 = [Math.sqrt(f), decimal.subtract(1, m), Math.sqrt(Math.pow(n, 3)), l];
      let num2 = 1;
      arr2.forEach((item) => {
        num2 = decimal.multiply(num2, item, 18);
      });

      this.form["d" + index + "6"] = decimal.divide(num1, num2, 0);
      this.calculateBbmjPjz();
    },
    // 计算平均值
    calculateBbmjPjz() {
      if (!this.form["d16"] || !this.form["d26"]) {
        this.form["d17Pjz"] = null;
        this.setFmhBgBbmj();
        return;
      }
      this.form["d17Pjz"] = decimal.divide(decimal.add(this.form["d16"], this.form["d26"]), 2, 0);
      this.setFmhBgBbmj();
    },
    // 给报告传值比表面积
    setFmhBgBbmj() {
      if (this.page != 0) {
        return;
      }
      Bus.$emit("setFmhBgJiancjg", [{ key: 102, value: this.form.d17Pjz }]);
    },
    // 试验温度改变
    wenduChange(index) {
      const info = this.shuiwenList.find((item) => item.temp == this.form["d" + index + "1"]);
      if (!info) {
        return;
      }
      this.form["d" + index + "4"] = info.viscosity;
      this.form["d" + index + "5"] = info.viscosity;
    },
    // 汇总盒号id
    collectHehId() {
      const arr = ["11", "21"];
      let hehIdList = [];
      arr.forEach((item) => {
        if (this.form["a" + item + "HehId"]) {
          hehIdList.push(this.form["a" + item + "HehId"]);
        }
      });
      this.form.hehIdList = hehIdList;
    },
    submitForm() {
      this.collectHehId();
      return this.form;
    },
    handleFocus(event) {
      handleFocus(event, this.page, this.form[event]);
    },
    handleKeyDown(event, rowIndex, colIndex) {
      const maxArr = [1, 1, 4, 1, 3, 3, 1];
      const ref = handleKeyDown(event, rowIndex, colIndex, maxArr);
      if (this.$refs[ref]) {
        this.$refs[ref].focus();
      }
    }
  }
};
</script>

<style scoped lang="scss">
.td-height1 {
  height: 40px;
}
</style>
